#!/bin/bash
set -e

cur_dir=`dirname $0`
cd $cur_dir
mailee="deepblue.zhm@gmail.com"
cur_date=`date +%Y%m%d`

# html format mail
title="Mail Title $cur_date\nContent-Type: text/html"
mail_body="./mailBody"

# make mail content
./makeMail.py > $mail_body

# send mail
cat $mail_body | mail -s "$(echo -e "$title")" $mailee

# delete old data
find ./data -type f -mtime +30 -exec rm -f {} \;
cd -

